<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Articles</title>
</head>
<body>
<f:view>
	<table cellspacing="0" cellpadding="5" width="100%">
		<%--HEADER--%>
		<tr>
			<td colspan="3"><!-- Begin HEAD --> <%@include file="common/header.jsp"%> <!-- END HEAD --></td>
		</tr>

		<tr>
			<%--NAVIGATION--%>
			<td valign="top" width="20%"><!-- Begin MENU -->
			<div id="menu"><%@include file="common/menu.jsp"%></div>
			<!-- END MENU --></td>
			<td align="left" valign="top" width="60%"><%--CENTRAL BODY--%> <f:subview id="body">
				<h:form id="listarticle">
					<c:if test="${empty sessionScope.member}">
						<h:dataTable value="#{articleManagedBean.articles}" var="ex">
							<h:column>
								<h:commandLink action="#{articleManagedBean.viewArticle}">
									<h:outputText value="#{ex.title}" />
									<f:param name="articleid" value="#{ex.id}" />
								</h:commandLink>
							</h:column>
							<h:column>
								<h:outputText value="#{ex.autor}" />
							</h:column>
							<h:column>
								<h:outputText value="#{ex.date}" />
							</h:column>
						</h:dataTable>
					</c:if>
					<!-- Session -->
					<c:if test="${not empty sessionScope.member}">
						<h:dataTable value="#{memberManagedBean.articles}" var="exx">
							<h:column>
								<h:commandLink action="#{articleManagedBean.viewArticle}">
									<h:outputText value="#{exx.title}" />
									<f:param name="articleid" value="#{exx.id}" />
								</h:commandLink>
							</h:column>
							<h:column>
								<h:outputText value="#{exx.autor}" />
							</h:column>

							<h:column>
								<h:commandButton value="Update" action="#{articleManagedBean.wantToUpdateArticle}" />
								<f:param name="articleid" value="#{exx.id}" />
							</h:column>
							<h:column>
								<h:commandButton value="Delete" action="#{articleManagedBean.deleteArticle}" />
								<f:param name="articleiid" value="#{exx.id}" />
							</h:column>
						</h:dataTable>
						<br />
						<br />
						<br />
						<h:commandButton value="add" action="#{articleManagedBean.wantToAddArticle}" />
					</c:if>




				</h:form>
			</f:subview></td>
		</tr>
		<%--FOOTER--%>
		<tr>
			<td colspan="3"><%@include file="common/footer.jsp"%></td>
		</tr>
	</table>
</f:view>
</body>
</html>